
package logic.beans;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Classe que representa um componente de uma droga.
 * 
 * @author Est�fano
 * @version 1.0 de 15/12/2008
 */
@Entity
@Table(
		name="COMPOSITIONS",
		uniqueConstraints={ @UniqueConstraint(columnNames={ "description","quantity","unit" }) })
public class Composition implements DBElementIF {
	private static final long serialVersionUID = -1594574770978523579L;
	
	private String description;
	private int quantity;
	private String unit;
	private Long id;
	
	public Composition() {
		this("",0,"");
	} 
	
	public Composition(String description,int quantity,String unit) {
		setDescription(description);
		setQuantity(quantity);
		setUnit(unit);
	}
	
	public void setDescription(String description) {
		this.description = description;
	}
	
	@Column(nullable=false)
	public String getDescription() {
		return description;
	}
	
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}
	
	@Column(nullable=false)
	public int getQuantity() {
		return quantity;
	}
	
	public void setUnit(String unit) {
		this.unit = unit;
	}
	
	@Column(nullable=false)
	public String getUnit() {
		return unit;
	}
	
	@SuppressWarnings("unused")
	private void setId(Long id) {
		this.id = id;
	}
	
	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}
	
	@Override
	public String toString() {
		return getDescription();
	}
}
